package com.jida.hadoop.mr.tools;

import java.io.IOException;
import java.util.Iterator;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import com.jida.hadoop.mr.tools.*;

public class DxFileUserReducer extends Reducer<Text, IntWritable, NullWritable, Text>{

	@Override
	protected void reduce(Text key, Iterable<IntWritable> values,
			Reducer<Text, IntWritable, NullWritable, Text>.Context context) throws IOException, InterruptedException {
		
		Iterator<IntWritable> it=values.iterator();
		int sum=0;
		while(it.hasNext()) {
			IntWritable temp=it.next();
			int i=temp.get();
			sum=sum+i;
		}
		String ovalue=key.toString()+TProperties.getValue("outfilesplit")+sum;
		context.write(NullWritable.get(),new Text(ovalue));
	}

}
